package com.xianggu.demo.service;

import com.xianggu.spring.annotation.AutoWired;
import com.xianggu.spring.annotation.Component;
import com.xianggu.spring.annotation.Resource;
import com.xianggu.spring.annotation.Scope;
import com.xianggu.spring.aware.BeanNameAware;
import com.xianggu.spring.aware.InitializingBean;

/**
 * @author chengjy
 * @date 2025/2/28
 */

@Component()
@Scope("prototype")
public class OrderService implements BeanNameAware, InitializingBean {
    @AutoWired("userService")
    public UserService userService;
    @Resource
    public BookService bookService;

    public String beanName;

    @Override
    public void afterPropertiesSet(){
        System.out.println("执行初始化逻辑");
    }

    public void test() {
        System.out.println("当前bean：1"+ beanName +" test:  " + userService);
        System.out.println("当前bean：2"+ beanName +" test:  " + bookService);
    }

    @Override
    public void setBeanName(String name) {
        this.beanName = name;
    }
}
